home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 406_01 / disked25 / source / dpb.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-13  |  4.7 KB  |  136 lines

  1. /***
  2. *dpb.h - definitions/declarations for DOS Drive Parameter Information
  3. *
  4. *Copyright (c) 1993-1994, Gregg Jennings.  All wrongs reserved.
  5. *   P O Box 200, Falmouth, MA 02541-0200
  6. *
  7. *Purpose:
  8. *   For use with the diskio() functions
  9. *   [ANSI/System V]
  10. *
  11. *******************************************************************************/
  12.  
  13. #ifndef GENERAL_H
  14. #include "general.h"
  15. #endif
  16.  
  17. /* DOS Disk structure definitions */
  18.  
  19. #pragma pack(1)
  20.  
  21. /* Format of a Boot Sector */
  22.  
  23. /* This is verbatim MS-DOS Technical Referance for DOS 3.3 */
  24.  
  25. struct BOOT {
  26.    unsigned char jump[3];           /* 3 byte Near Jump to boot code */
  27.    unsigned char name[8];           /* 8 byte OEM name and version */
  28.    unsigned int  sec_size; /*BPB*/  /* WORD Bytes per sector */
  29.    unsigned char secs_cluster;      /* BYTE Sectors per allocation unit */
  30.    unsigned int  reserved_secs;     /* WORD Reserved sectors (note 1) */
  31.    unsigned char num_fats;          /* BYTE Number of FATs */
  32.    unsigned int  dir_entries;       /* WORD Number of root dir entries */
  33.    unsigned int  num_sectors;       /* WORD Number of sectors in logical
  34.                                        image or 0 (note 2) */
  35.    unsigned char media_desc;        /* BYTE Media descriptor */
  36.    unsigned int  secs_fat; /*BPB*/  /* WORD Number of FAT sectors */
  37.    unsigned int  secs_track;        /* WORD Sectors per track */
  38.    unsigned int  num_heads;         /* WORD Number of heads */
  39.    unsigned int  hidden_sectors;    /* WORD Number of hidden sectors (note 3) */
  40.    unsigned int  large_sectors;     /* WORD High order number of hidden
  41.                                        sectors */
  42.    unsigned long total_sectors;     /* DWORD Number of logical sectors */
  43.  
  44.    /*
  45.       I've added this to keep it the same as the BPB structure defined
  46.       later.
  47.    */
  48.    unsigned char reserved[6];
  49. };
  50.  
  51. /* This is the text from the Technical Reference:
  52.  
  53.    "Although MS-DOS does not use the five fields that follow the BPB, these
  54.    fields may be used by a device driver to help it understand the media.
  55.  
  56.    "The "Sectors per track" and "Number of heads" fields are useful for
  57.    supporting different media that may have the same logical layout, but
  58.    a different physical layout (for example, 40-track, double-sided versus
  59.    80-track, single-sided). "Sectors per track" tells the device driver how
  60.    the logical disk format is laid out on the physical disk.
  61.  
  62.    "The "Number of hidden sectors" and "High order number of hidden
  63.    sectors" fields may be used to support drive-partitioning schemes.
  64.  
  65.    The "Number of logical sectors" field tells the device driver how many
  66.    sectors to reserve if the "Number of sectors in logical image" field is zero
  67.    (Notice taht this is intended for supporting devices that access more than
  68.    32 megabytes.)"
  69.  
  70.    Note 1: Reserved sectors are the number of sectors that make up the
  71.    boot record.  Although usually 1 that is not always the case.
  72.  
  73.    Mote 2: If the num_sectors is 0, then there are more than can fit
  74.    in a WORD (65535), i.e. > 32 megabytes (this is how DOS has changed
  75.    to support "un-thought-of" drive sizes), and total_sectors must be
  76.    used. (This is an assumption on my part.)
  77.  
  78.    Note 3: Hidden sectors are for hard-drives to hold Partitioning
  79.    information.  They are "hidden" from DOS Interrupts 25 and 26, and BIOS
  80.    Interrupt 13, but can be accessed by DOS Interrupt 21/44. (Interrupt
  81.    13 may read them, but I have not tried it.)
  82.    There has been a problem with 'hidden_sectors'.  BPB says DWORD but
  83.    BOOT says WORD (?); WORD seems to work but I've found that it also
  84.    depends on the compiler and the optimizations ;-).
  85.  
  86. */
  87.  
  88. /* BIOS Parameter Block definition */
  89.  
  90. /*
  91.    There are more fields than described by the BPB area of the BOOT
  92.    structure as defined by MS (bounded by / *BPB* / above), but they are
  93.    the same except for the "reserved" bytes at the end.
  94. */
  95.  
  96. struct BPB {
  97.    unsigned int  sec_size;
  98.    unsigned char secs_cluster;
  99.    unsigned int  reserved_secs;
  100.    unsigned char num_fats;
  101.    unsigned int  dir_entries;
  102.    unsigned int  num_sectors;
  103.    unsigned char media_desc;
  104.    unsigned int  secs_fat;
  105.    unsigned int  secs_track;
  106.    unsigned int  num_heads;
  107.    unsigned long hidden_sectors;
  108.    unsigned long total_sectors;
  109.    unsigned char reserved[6];
  110. };
  111.  
  112. /* Disk Parameter Block */
  113.  
  114. /* IOCTL Int 21/44 interface */
  115.  
  116. struct DPB {
  117.    unsigned char special;
  118.    unsigned char dev_type;
  119.    unsigned int  dev_attrib;
  120.    unsigned int  cylinders;
  121.    unsigned char media;
  122.    struct BPB bpb;
  123. };
  124.  
  125. /* Disk Control Block */
  126.  
  127. /* For drives larger than 32M */
  128.  
  129. struct DCB {
  130.      unsigned long sector;
  131.      unsigned int  number;
  132.      unsigned char _far *buffer;
  133. };
  134.  
  135. #pragma pack()
  136.